using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace WebSite.Controllers
{
    public class SidebarController : Controller
    {
        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Menu()
        {
            return View("Menu");
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Menu(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string key = formCollection.GetKey(0);
                if (key == "jobs")
                    return RedirectToAction("Index", "JobsManagement");//View("Index");
                else if (key == "questions")
                    return RedirectToAction("Index", "Questions");
                else if (key == "questionnaire")
                    return RedirectToAction("Questionnaire", "Questionnaire");
                else if (key == "logout")
                {
                    if (User.Identity.IsAuthenticated)
                        FormsAuthentication.SignOut();
                    return Redirect(Url.Action("LogOn", "Account"));
                }
            }
            else
                throw new Exception();
            return null;
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult AdminMenu()
        {
            return View("AdminMenu");
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult AdminMenu(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string key = formCollection.GetKey(0);

                if (key == "Users")
                {
                    return Redirect(Url.Action("Index", "UserAdministration"));
                }
                if (key == "Roles")
                {
                    return Redirect(Url.Action("RolesMain", "UserAdministration"));
                }
                if (key == "logout")
                {
                    if (User.Identity.IsAuthenticated)
                        FormsAuthentication.SignOut();
                    return Redirect(Url.Action("LogOn", "Account"));
                }
            }
            else
                throw new Exception();
            return null;
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult HiringManagerMenu()
        {
            return View("HiringManagerMenu");
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult HiringManagerMenu(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string key = formCollection.GetKey(0);

                if (key == "Applications")
                {
                    return Redirect(Url.Action("Index", "StoreManagerInterview"));
                }
                if (key == "Stores")
                {
                    return Redirect(Url.Action("Index", "StoresManagement"));
                }
                if (key == "logout")
                {
                    if (User.Identity.IsAuthenticated)
                        FormsAuthentication.SignOut();
                    return Redirect(Url.Action("LogOn", "Account"));
                }
            }
            else
                throw new Exception();
            return null;
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult HiringSpecialistMenu()
        {
            return View("HiringSpecialistMenu");
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult HiringSpecialistMenu(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string key = formCollection.GetKey(0);

                if (key == "Applications")
                {
                    return Redirect(Url.Action("Index", "PhoneInterview"));
                }
                if (key == "logout")
                {
                    if (User.Identity.IsAuthenticated)
                        FormsAuthentication.SignOut();
                    return Redirect(Url.Action("LogOn", "Account"));
                }
            }
            else
                throw new Exception();
            return null;
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult ApplicantMenu()
        {
            return View("ApplicantMenu");
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult ApplicantMenu(FormCollection formCollection)
        {
            if (formCollection.HasKeys())
            {
                string key = formCollection.GetKey(0);

                if (key == "logout")
                {
                    if (User.Identity.IsAuthenticated)
                        FormsAuthentication.SignOut();
                    return Redirect(Url.Action("LogOn", "Account"));
                }
            }
            else
                throw new Exception();
            return null;
        }
    }
}
